<?php
/**
*	@author SignpostMarv Martin
*	@package UHU
*	@subpackage UHU_Config
**/

/**
*	Exception class used by {@link uhu_install_config}
*	@package UHU_exception
*	@subpackage UHU_Config
**/
class uhu_install_config_exception extends uhu_exception{
	protected function getExtendedMessage($code=null)
	{
		return '%s';
	}
}

/**
*	Avoids the use of global variables for installation configuration data.
*	Will at some point get a lock method, forcing {@link uhu_install_config::set()} to throw an {@link uhu_install_config_exception Exception} even if override param set to TRUE
*	@package UHU
*	@subpackage UHU_Config
**/
class uhu_install_config
{
	protected static $config = array();
	public static function get($param)
	{
		return isset(self::$config[$param]) ? self::$config[$param] : null;
	}
	public static function set($param,$val,$override=false)
	{
		if(is_string($param) === false)
		{
			throw new uhu_install_config_exception('Parameter should be specified as string.');
		}
		else if(isset(self::$config[$param]) && $override === false)
		{
			throw new uhu_install_config_exception('Attempt to set already defined value \'' . $param . '\'');
		}
		self::$config[$param] = $val;
	}
}
?>